import japa.parser.*;
import japa.parser.ast.CompilationUnit;
import japa.parser.ast.body.MethodDeclaration;
import japa.parser.ast.visitor.VoidVisitorAdapter;

import java.io.File;
import java.io.FileInputStream;

import javax.swing.JFileChooser;
import javax.swing.JFrame;

public class MethodPrinter {

        	
    	public MethodPrinter(CompilationUnit cu){ 
       

        // visit and print the methods names
        MethodVisitor mv = new MethodVisitor();
        mv.visit(cu, null);
        mv.printCount();
        
    }

    /**
     * Simple visitor implementation for visiting MethodDeclaration nodes. 
     */
    private static class MethodVisitor extends VoidVisitorAdapter {
    	int count=0;
        
    	@Override
        public void visit(MethodDeclaration n, Object arg) {
            // here you can access the attributes of the method.
            // this method will be called for all methods in this 
            // CompilationUnit, including inner class methods
        	count ++;
        	System.out.println('\t' + n.getName());
                    
        }
        
        public void printCount(){
        	System.out.println("Total Method Count " + count);
        	System.out.println('\n');
        }
    }
    }
